package com.shrct.businessprocess.customerservice.impl;

import com.shrct.businessprocess.customerservice.RCFaultReport;
import com.shrct.businessprocess.customerservice.RCFaultReportEvent;
import com.shrct.businessprocess.customerservice.RCFaultReportEventType;
import com.shrct.businessprocess.customerservice.impl.RCFaultReportImpl;
import com.shrct.businessprocess.customerservice.proxy.RCFaultReportEventProxy;
import com.shrct.businessprocess.organization.RCEmployee;
import com.shrct.businessprocess.organization.impl.RCEmployeeImpl;
import edu.fudan.mylang.pf.BaseModelObject;
import edu.fudan.mylang.pf.IObjectFactory;
import java.util.Date;
import javax.persistence.CascadeType;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
import org.hibernate.annotations.DiscriminatorOptions;

@Entity
@DiscriminatorValue("RCFAULTREPORTEVENT_TYPE")
@DiscriminatorOptions(force = true)
@DiscriminatorColumn(length = 64)
@Table(name = "rcfaultreportevent")
public class RCFaultReportEventImpl extends BaseModelObject implements RCFaultReportEvent {
  public RCFaultReportEventImpl() {
    super();
  }
  
  public RCFaultReportEventImpl(final RCFaultReport faultReport) {
    super();
    this.faultReport = faultReport;
  }
  
  @JoinColumn(name = "faultReport_id")
  @ManyToOne(targetEntity = RCFaultReportImpl.class, cascade = { CascadeType.MERGE, CascadeType.PERSIST })
  private RCFaultReport faultReport;
  
  public RCFaultReport getFaultReport() {
    return this.faultReport;
  }
  
  public RCFaultReportEvent setFaultReport(final RCFaultReport faultReport) {
    this.faultReport = faultReport;
    return this;			
    
  }
  
  private Date dateTime;
  
  public Date getDateTime() {
    return this.dateTime;
  }
  
  public RCFaultReportEvent setDateTime(final Date dateTime) {
    this.dateTime = dateTime;
    return this;			
    
  }
  
  private RCFaultReportEventType type;
  
  public RCFaultReportEventType getType() {
    return this.type;
  }
  
  public RCFaultReportEvent setType(final RCFaultReportEventType type) {
    this.type = type;
    return this;			
    
  }
  
  @JoinColumn(name = "operator_id")
  @ManyToOne(targetEntity = RCEmployeeImpl.class, cascade = { CascadeType.MERGE, CascadeType.PERSIST })
  private RCEmployee operator;
  
  public RCEmployee getOperator() {
    return this.operator;
  }
  
  public RCFaultReportEvent setOperator(final RCEmployee operator) {
    this.operator = operator;
    return this;			
    
  }
  
  private String comment;
  
  public String getComment() {
    return this.comment;
  }
  
  public RCFaultReportEvent setComment(final String comment) {
    this.comment = comment;
    return this;			
    
  }
  
  public void update(final Procedure1<? super RCFaultReportEvent> updater) {
    updater.apply(this);
  }
  
  public static RCFaultReportEvent create(final RCFaultReport faultReport, final IObjectFactory objectFactory) {
    com.shrct.businessprocess.customerservice.RCFaultReportEvent rCFaultReportEvent = new com.shrct.businessprocess.customerservice.impl.RCFaultReportEventImpl(
    	faultReport
    );
    objectFactory.create(rCFaultReportEvent);
    return rCFaultReportEvent;			
    
  }
  
  public static RCFaultReportEvent createRCFaultReportEventImpl(final RCFaultReport faultReport, final IObjectFactory objectFactory, final Procedure1<RCFaultReportEvent> init) {
    com.shrct.businessprocess.customerservice.RCFaultReportEvent rCFaultReportEvent = new com.shrct.businessprocess.customerservice.impl.RCFaultReportEventImpl(
    	faultReport
    );
    objectFactory.create(rCFaultReportEvent);
    init.apply(rCFaultReportEvent);
    
    return rCFaultReportEvent;			
    
  }
  
  public RCFaultReportEventProxy toProxy() {
    com.shrct.businessprocess.customerservice.proxy.RCFaultReportEventProxy proxy = new com.shrct.businessprocess.customerservice.proxy.RCFaultReportEventProxy();
    proxy.setId(this.getId());
    if(this instanceof edu.fudan.mylang.pf.INamedModelObject){
    	proxy.setName(((edu.fudan.mylang.pf.INamedModelObject)this).getEntityName());
    }
    return proxy;
    
  }
}
